package com.sgb.kjwl.view.ui.activity.transport;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
import com.amap.api.maps.UiSettings;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.alimaplibrary.MapMarkerTools;
import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityBiddingOrderDetailsBinding;
import com.sgb.kjwl.model.entity.transport.BiddingOrderDetailsEntity;
import com.sgb.kjwl.model.entity.transport.OperateGoodsSourcePlaceVO;
import com.sgb.kjwl.model.entity.transport.TransportOrderEntity;
import com.sgb.kjwl.model.entity.transport.common.AddressItem;
import com.sgb.kjwl.utils.CargoConstant;
import com.sgb.kjwl.utils.NumberUtil;
import com.sgb.kjwl.view.ui.activity.self.logistics.OfferOwnerActivity;
import com.sgb.kjwl.view.ui.activity.transport.driver.goods.FreightPrjDetailActivity;
import com.sgb.kjwl.view.ui.adapter.transport.TransportInfoAdapter;
import com.sgb.kjwl.view.ui.adapter.transport.TransportOrderDetailAddressAdapter;
import com.sgb.kjwl.view.widget.WrapLinearLayout;
import com.sgb.kjwl.viewmodel.self.logistics.BiddingOrderDetailsModel;
import com.swgk.core.dialog.RoundDialog;
import com.swgk.core.util.DateUtils;
import com.swgk.core.util.MLog;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

/**
 * Describe:    竞价订单详情
 * Author:  yangLei
 * Date:    2021/7/16
 */
public class BiddingOrderDetailsActivity extends AppActivity implements TransportOrderDetailAddressAdapter.ItemOnClickListen {

    private ActivityBiddingOrderDetailsBinding mBinding;
    //0为货主查询 1为企业/团队/车主查询
    private int isOwner;
    private String orderNo;
    private List<String> mListString;//货源信息
    //    private TransportInfoAdapter mAdapter;
    private BiddingOrderDetailsModel viewModel;
    public final static String POSITION_CARRIER = "发货单位";
    public final static String POSITION_DEST = "终点位置";

    private AMap aMap;    //地图控制器
    private MapView mapView;    //高德3DMap  地图显示View
    private Bundle savedInstanceState;

    private TransportOrderDetailAddressAdapter transportOrderDetailAddressAdapter;//运输订单详情地址
    private BiddingOrderDetailsEntity mEntity;

    /**
     * @param context
     * @param orderNo 竞价订单编号
     * @param isOwner 是否为货主:0为货主查询 1为企业/团队/车主查询
     */
    public static void start(Context context, String orderNo, int isOwner) {
        Intent intent = new Intent(context, BiddingOrderDetailsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.putExtra("no", orderNo);
        intent.putExtra("isOwner", isOwner);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.savedInstanceState = savedInstanceState;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
        //在activity执行onDestroy时执行mMapView.onDestroy()，销毁地图
        if (mapView != null)
            mapView.onDestroy();
    }

    @Override
    protected void onResume() {
        super.onResume();
        //在activity执行onResume时执行mMapView.onResume ()，重新绘制加载地图
        if (mapView != null)
            mapView.onResume();
        if (!TextUtils.isEmpty(orderNo)) {
            viewModel.getDetails(this, isOwner, orderNo);
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        //在activity执行onPause时执行mMapView.onPause ()，暂停地图的绘制
        if (mapView != null)
            mapView.onPause();
    }

    @Override
    protected void initView() {
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_bidding_order_details);
        mBinding.actionBar.setTitle("竞价订单");
        mBinding.actionBar.setOnBackClickListener(v -> finish());
        //scrollview 和 Map嵌套产生的滑动冲突解决
        mBinding.mapContainer.setScrollView(mBinding.scrollView);
        mapView = mBinding.map;
        viewModel = new ViewModelProvider(this).get(BiddingOrderDetailsModel.class);
        isOwner = getIntent().getIntExtra("isOwner", 1);
        orderNo = getIntent().getStringExtra("no");

        initMap();
        initClickListener();

        viewModel.detailsLD.observe(this, entity -> fillData(entity));
        viewModel.ldMapLoadFinish.observe(this, aBoolean -> mBinding.mapLayout.setVisibility(View.VISIBLE));
        viewModel.ldCurrAddress.observe(this, this::showLocationInfoDialog);
        viewModel.ldLatLng.observe(this, latLng -> {
            if (latLng != null && mEntity != null) {
                MLog.d("api", "latLng：（" + latLng.latitude + "," + latLng.longitude + "）");
                mEntity.setLatitude(latLng.latitude);
                mEntity.setLongitude(latLng.longitude);
                if (aMap != null) {
                    viewModel.loadMapInfo(mEntity, aMap);
                }
            }
        });
    }

    /**
     * 显示地图上marker信息对话框
     */
    private void showLocationInfoDialog(AddressItem addressItem) {
        if (addressItem == null) {
            mBinding.windowAddress.setVisibility(View.GONE);
            return;
        }
        if (!TextUtils.isEmpty(addressItem.getAddressdetail()) || !TextUtils.isEmpty(addressItem.getAddressName())) {
            StringBuilder add = new StringBuilder();
            if (!TextUtils.isEmpty(addressItem.getIntroduce())) {
                if (addressItem.getIntroduce().equals(POSITION_CARRIER)) {
                    //展示报价人位置信息
                    if (!TextUtils.isEmpty(mEntity.getCarrierUser())) {
                        mBinding.popName.setText(mEntity.getCarrierUser());
                        mBinding.popName.setVisibility(View.VISIBLE);
                    } else {
                        mBinding.popName.setVisibility(View.GONE);
                    }
                    if (!TextUtils.isEmpty(mEntity.getCarrierNumber())) {
                        mBinding.popPhone.setText(mEntity.getCarrierNumber());
                        mBinding.popPhone.setVisibility(View.VISIBLE);
                    } else {
                        mBinding.popPhone.setVisibility(View.GONE);
                    }
                    if (TextUtils.isEmpty(mEntity.getCarrierUser()) && TextUtils.isEmpty(mEntity.getCarrierNumber())) {
                        mBinding.popPhoneLayout.setVisibility(View.GONE);
                    } else
                        mBinding.popPhoneLayout.setVisibility(View.VISIBLE);
                } else if (addressItem.getIntroduce().equals(POSITION_DEST)) {
                    if (!TextUtils.isEmpty(mEntity.getReceptionPeople())) {
                        mBinding.popName.setText(mEntity.getReceptionPeople());
                        mBinding.popName.setVisibility(View.VISIBLE);
                    } else {
                        mBinding.popName.setVisibility(View.GONE);
                    }
                    if (!TextUtils.isEmpty(mEntity.getReceptionPhone())) {
                        mBinding.popPhone.setText(mEntity.getReceptionPhone());
                        mBinding.popPhone.setVisibility(View.VISIBLE);
                    } else {
                        mBinding.popPhone.setVisibility(View.GONE);
                    }
                    if (TextUtils.isEmpty(mEntity.getReceptionPeople()) && TextUtils.isEmpty(mEntity.getReceptionPhone())) {
                        mBinding.popPhoneLayout.setVisibility(View.GONE);
                    } else
                        mBinding.popPhoneLayout.setVisibility(View.VISIBLE);
                } else {
                    add.append(addressItem.getAddressName());
                    mBinding.popPhoneLayout.setVisibility(View.GONE);
                }
            }
            add.append(!TextUtils.isEmpty(addressItem.getAddressdetail()) ? addressItem.getAddressdetail() : "");
            mBinding.popAddress.setText(add.toString());
        }
        mBinding.windowAddress.setVisibility(View.VISIBLE);
    }

    /**
     * 初始化地图
     */
    private void initMap() {
        mapView.onCreate(savedInstanceState);
        aMap = mapView.getMap();
        viewModel.setMapMarkerTools(new MapMarkerTools(getActivity(), getLifecycle(), false));
        UiSettings uiSettings = aMap.getUiSettings();//地图的UI设置控制器
        uiSettings.setAllGesturesEnabled(true);//手势操作
        uiSettings.setCompassEnabled(false);// 设置指南针是否显示
        uiSettings.setZoomControlsEnabled(false);// 设置缩放按钮是否显示
        uiSettings.setScaleControlsEnabled(false);// 设置比例尺是否显示
        uiSettings.setRotateGesturesEnabled(false);// 设置地图旋转是否可用
        uiSettings.setTiltGesturesEnabled(true);// 设置地图倾斜是否可用
        uiSettings.setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示
    }

    /**
     * 设置数据
     *
     * @param entity
     */
    @SuppressLint("ClickableViewAccessibility")
    private void fillData(BiddingOrderDetailsEntity entity) {
        if (entity == null)
            return;
        else mEntity = entity;

        //状态先不管，只有待确认（2.0.8）
/*        if (entity.getStatus() != null) {
            //订单状态 0待付款 1待确认 2待发车 3运输中 4已完成 5已取消
            switch (entity.getStatus()) {
                case 0:
                    mBinding.orderStatue.setText("待付款");
                    break;
                case 1:
                    mBinding.orderStatue.setText("待确");
                    break;
                case 2:
                    mBinding.orderStatue.setText("待发车");
                    break;
                case 3:
                    mBinding.orderStatue.setText("运输中");
                    break;
                case 4:
                    mBinding.orderStatue.setText("已完成");
                    break;
                case 5:
                    mBinding.orderStatue.setText("已取消");
                    break;
            }
        }*/

        /*物流地图*/
        if (entity.getLongitude() > 0 && entity.getLatitude() > 0 && aMap != null) {
            viewModel.loadMapInfo(mEntity, aMap);
        } else {
            if (!TextUtils.isEmpty(entity.getAddress())) {
                viewModel.getLocation(this, entity.getAddress());
            } else if (aMap != null) {
                viewModel.loadMapInfo(mEntity, aMap);
            }
        }

        if (!TextUtils.isEmpty(entity.getFreight())) {
            mBinding.freightUnit.setText(NumberUtil.trim0(entity.getFreight()) + "元/吨");
        } else {
            mBinding.freightUnit.setText("/");
        }

        /*承运单位信息*/
        if (!TextUtils.isEmpty(entity.getCarrierUnit())) {
            mBinding.carrierUnitName.setText(entity.getCarrierUnit());
        }
        if (!TextUtils.isEmpty(entity.getCarrierUser())) {
            mBinding.contactName.setText(entity.getCarrierUser());
        }
        if (!TextUtils.isEmpty(entity.getCarrierNumber())) {
            mBinding.contactNum.setText(entity.getCarrierNumber());
        }
        //个人报价->需要额外展示车辆信息
        if (!TextUtils.isEmpty(entity.getOfferType())) {
            if (entity.getOfferType().equals("3")) {
                StringBuilder carInfo = new StringBuilder();
                if (!TextUtils.isEmpty(entity.getCarTypeName())) {
                    carInfo.append(entity.getCarTypeName() + "/");
                }
                if (!TextUtils.isEmpty(entity.getCarLenName())) {
                    carInfo.append("长" + entity.getCarLenName() + "/");
                }
                if (!TextUtils.isEmpty(entity.getWeight())) {
                    carInfo.append("额定载重" + NumberUtil.trim0(entity.getWeight()) + "吨/");
                }
                if (!TextUtils.isEmpty(entity.getHeightHurdle())) {
                    carInfo.append("栏高" + NumberUtil.trim0(entity.getHeightHurdle()) + "米/");
                }
                if (!TextUtils.isEmpty(entity.getFunctionNos())) {
                    carInfo.append(entity.getFunctionNos() + "/");
                }
                if (!TextUtils.isEmpty(carInfo.toString()) && carInfo.toString().length() > 0) {
                    mBinding.carrierCarInfo.setText(carInfo.substring(0, carInfo.length() - 1));
                    mBinding.carrierCarInfoLayout.setVisibility(View.VISIBLE);
                } else {
                    mBinding.carrierCarInfoLayout.setVisibility(View.GONE);
                }
            } else {
                mBinding.carrierCarInfoLayout.setVisibility(View.GONE);
            }
            mBinding.estimatedTimeOfArrivalLayout.setVisibility(entity.getInTime()==null?View.GONE:View.VISIBLE);
            mBinding.estimatedTimeOfArrival.setText(entity.getInTime()==null?"/":DateUtils.stampToDay5(entity.getInTime()));
        }


        /*发货单位信息*/
/*        if (!TextUtils.isEmpty(entity.getOfferType())) {
            switch (entity.getOfferType()) {
                case "1"://企业
                    if (!TextUtils.isEmpty(entity.getCompanyName())){
                        mBinding.unitName.setTag(entity.getCompanyName());
                    }
                    break;
                case "2"://团队
                    if (!TextUtils.isEmpty(entity.getTeamName())){
                        mBinding.unitName.setTag(entity.getTeamName());
                    }
                    break;
                case "3"://个人
                    break;
            }
        }*/
        if (!TextUtils.isEmpty(entity.getHeadImg()))
            Glide.with(this).load(entity.getHeadImg()).apply(new RequestOptions()
                    .placeholder(R.mipmap.goods_info_default_avartor)
                    .fallback(R.mipmap.goods_info_default_avartor)
                    .error(R.mipmap.goods_info_default_avartor)).into(mBinding.ivHeader);

        if (!TextUtils.isEmpty(entity.getForwardingUnit())) {
            mBinding.unitName.setText(entity.getForwardingUnit());
        }
        if (!TextUtils.isEmpty(entity.getShipper())) {
            mBinding.sendContactName.setText(entity.getShipper());
        }
        if (!TextUtils.isEmpty(entity.getShipperNumber())) {
            mBinding.sendContactPhone.setText(entity.getShipperNumber());
        }

        /*货物信息*/
        if (mListString == null)
            mListString = new ArrayList<>();
        mListString.clear();
        if (!TextUtils.isEmpty(entity.getGoodsTypeName()))
            mListString.add(entity.getGoodsTypeName()+(TextUtils.isEmpty(entity.getSecondGoodsTypeName())?"":"/"+entity.getSecondGoodsTypeName()));
        if (!TextUtils.isEmpty(entity.getGoodsWeight()) && !entity.getGoodsWeight().equals("0"))
            mListString.add(NumberUtil.trim0(entity.getGoodsWeight()) + "吨");
        if (!TextUtils.isEmpty(entity.getGoodsVolume()) && !entity.getGoodsVolume().equals("0"))
            mListString.add(NumberUtil.trim0(entity.getGoodsVolume()) + "方");
        mBinding.sourceDetailsLl.setOnClickListener(this);
        loadGoodsSourceInfo(mListString, mBinding.goodsInfoLayout);

        /*装卸信息*/
        if (!TextUtils.isEmpty(entity.getHandleTypeName())) {
            mBinding.loadingType.setText("装卸方式：" + entity.getHandleTypeName());
        }
        if (entity.getPlace() != null) {
            List<AddressItem> items = new ArrayList<>();
            initSettingItem(items, entity.getPlace(), entity.getHandleTypeName(), entity);
            transportOrderDetailAddressAdapter = new TransportOrderDetailAddressAdapter(items, entity.getPlace());
            transportOrderDetailAddressAdapter.SetItemOnClickListen(this);
            mBinding.rvAddress.setLayoutManager(new LinearLayoutManager(getActivity()));
            mBinding.rvAddress.setAdapter(transportOrderDetailAddressAdapter);
        }

        /*订单信息*/
        if (!TextUtils.isEmpty(entity.getOrderNo())) {
            mBinding.orderNo.setText("订单编号：" + entity.getOrderNo());
        }
        if (entity.getCreateTime() > 0) {
            mBinding.orderTime.setText("下单时间：" + DateUtils.formatDate(entity.getCreateTime(), ""));
        }

        mBinding.scrollView.setVisibility(View.VISIBLE);
    }

    @SuppressLint("ClickableViewAccessibility")
    private void initClickListener() {
        mBinding.tvOnline.setOnClickListener(this::onMultiClick);
        mBinding.contactNum.setOnClickListener(this::onMultiClick);
        mBinding.tvCallContact.setOnClickListener(this::onMultiClick);
        //隐藏物流地图弹窗
        mBinding.windowAddress.setOnTouchListener((v, event) -> {
            showLocationInfoDialog(null);
            return false;
        });
        mBinding.popPhoneLayout.setOnClickListener(this::onMultiClick);
    }

    @Override
    public void onMultiClick(View v) {
        switch (v.getId()) {
            case R.id.contact_num:
                if (!TextUtils.isEmpty(mEntity.getCarrierNumber())) {
                    showTelDialog(mEntity.getCarrierNumber());
                }
                break;

            case R.id.pop_phone_layout:
                if (!TextUtils.isEmpty(mBinding.popPhone.getText().toString())) {
                    showTelDialog(mBinding.popPhone.getText().toString().trim());
                }
                break;

            //跳转货源详情页面
            case R.id.source_details_ll:
                if (!TextUtils.isEmpty(mEntity.getGoodsSourceNo()))
                    FreightPrjDetailActivity.start(this, mEntity.getGoodsSourceNo(), true, false);
                break;

            case R.id.tv_online://在线联系
                if (mEntity != null && !TextUtils.isEmpty(mEntity.getImAccount())) {
                    // TODO IM功能目前需要全部去掉，此处需要后期IM迁移完成后完善
                    buildSingleTalking(mEntity.getImAccount());
                }
                break;

            case R.id.tv_call_contact://拨打电话
                if (mEntity != null)
                    if (isOwner == 0 && !TextUtils.isEmpty(mEntity.getCarrierNumber())) {//货主
                        showTelDialog(mEntity.getCarrierNumber());
                    } else if (isOwner == 1 && !TextUtils.isEmpty(mEntity.getShipperNumber())) {//承运方
                        showTelDialog(mEntity.getShipperNumber());
                    }
                break;
        }
    }

    /**
     * 装载货源信息
     */
    private void loadGoodsSourceInfo(List<String> strings, WrapLinearLayout lay_gallery) {
        lay_gallery.removeAllViews();
        LayoutInflater mInflater = LayoutInflater.from(getActivity());
        if (strings != null && strings.size() != 0) {
            for (int i = 0; i < strings.size(); i++) {
                final View view = mInflater.inflate(R.layout.item_goods_transport_info_02, lay_gallery, false);
                final TextView tv_info = view.findViewById(R.id.tv_info);
                tv_info.setText(strings.get(i));
                lay_gallery.addView(view);
            }
        }
    }

    /**
     * 初始化功能列表
     */
    public void initSettingItem(List<AddressItem> list, OperateGoodsSourcePlaceVO
            sourcePlace, String handleTypeNo, BiddingOrderDetailsEntity entity) {
        if (list == null) return;
        list.clear();
        if ("一装一卸".equals(handleTypeNo)) {//一装一卸
            list.add(new AddressItem(sourcePlace.getProvinceName() + "  " + sourcePlace.getCityName() + "  " + sourcePlace.getDistrictName(), sourcePlace.getDetailAddress(), sourcePlace.getFirstDistance(), true, R.mipmap.icon_load_goods, handleTypeNo, 0,
                    entity.getShipmentTime(), entity.getStartPointTime(), entity.getShipmentEndTime(), entity.getEndPointTime(), 0));
            list.add(new AddressItem(sourcePlace.getDestProvinceName() + "  " + sourcePlace.getDestCityName() + "  " + sourcePlace.getDestDistrictName(), sourcePlace.getDestDetailAddress(), null, false, R.mipmap.icon_unload_goods, handleTypeNo, 1,
                    0, 0, entity.getArrivalTime()));
        } else if ("一装两卸".equals(handleTypeNo)) {//一装两卸
            list.add(new AddressItem(sourcePlace.getProvinceName() + "  " + sourcePlace.getCityName() + "  " + sourcePlace.getDistrictName(), sourcePlace.getDetailAddress(), sourcePlace.getFirstDistance(), true, R.mipmap.icon_load_goods, handleTypeNo, 0,
                    entity.getShipmentTime(), entity.getStartPointTime(), entity.getShipmentEndTime(), entity.getEndPointTime(), 0));
            list.add(new AddressItem(sourcePlace.getViaDestProvinceName() + "  " + sourcePlace.getViaDestCityName() + "  " + sourcePlace.getViaDestDistrictName(), sourcePlace.getViaDestDetailAddress(), sourcePlace.getSecondDistance(), true, R.mipmap.icon_unload_one, handleTypeNo, 1));
            list.add(new AddressItem(sourcePlace.getDestProvinceName() + "  " + sourcePlace.getDestCityName() + "  " + sourcePlace.getDestDistrictName(), sourcePlace.getDestDetailAddress(), null, false, R.mipmap.icon_unload_two, handleTypeNo, 2,
                    0, 0, entity.getArrivalTime()));
        } else if ("两装一卸".equals(handleTypeNo)) {//两装一卸
            list.add(new AddressItem(sourcePlace.getProvinceName() + "  " + sourcePlace.getCityName() + "  " + sourcePlace.getDistrictName(), sourcePlace.getDetailAddress(), sourcePlace.getFirstDistance(), true, R.mipmap.icon_load_one, handleTypeNo, 0,
                    entity.getShipmentTime(), entity.getStartPointTime(), entity.getShipmentEndTime(), entity.getEndPointTime(), 0));
            list.add(new AddressItem(sourcePlace.getViaSendProvinceName() + "  " + sourcePlace.getViaSendCityName() + "  " + sourcePlace.getViaSendDistrictName(), sourcePlace.getViaSendDetailAddress(), sourcePlace.getSecondDistance(), true, R.mipmap.icon_load_two, handleTypeNo, 1));
            list.add(new AddressItem(sourcePlace.getDestProvinceName() + "  " + sourcePlace.getDestCityName() + "  " + sourcePlace.getDestDistrictName(), sourcePlace.getDestDetailAddress(), null, false, R.mipmap.icon_unload_goods, handleTypeNo, 2,
                    0, 0, entity.getArrivalTime()));
        } else if ("两装两卸".equals(handleTypeNo)) {
            list.add(new AddressItem(sourcePlace.getProvinceName() + "  " + sourcePlace.getCityName() + "  " + sourcePlace.getDistrictName(), sourcePlace.getDetailAddress(), sourcePlace.getFirstDistance(), true, R.mipmap.icon_load_one, handleTypeNo, 0,
                    entity.getShipmentTime(), entity.getStartPointTime(), entity.getShipmentEndTime(), entity.getEndPointTime(), 0));
            list.add(new AddressItem(sourcePlace.getViaSendProvinceName() + "  " + sourcePlace.getViaSendCityName() + "  " + sourcePlace.getViaSendDistrictName(), sourcePlace.getViaSendDetailAddress(), sourcePlace.getSecondDistance(), true, R.mipmap.icon_load_two, handleTypeNo, 1));
            list.add(new AddressItem(sourcePlace.getViaDestProvinceName() + "  " + sourcePlace.getViaDestCityName() + "  " + sourcePlace.getViaDestDistrictName(), sourcePlace.getViaDestDetailAddress(), sourcePlace.getThirdDistance(), true, R.mipmap.icon_unload_one, handleTypeNo, 2));
            list.add(new AddressItem(sourcePlace.getDestProvinceName() + "  " + sourcePlace.getDestCityName() + "  " + sourcePlace.getDestDistrictName(), sourcePlace.getDestDetailAddress(), null, false, R.mipmap.icon_unload_two, handleTypeNo, 3,
                    0, 0, entity.getArrivalTime()));
        }
    }

    @Override
    public void onItemClick(OperateGoodsSourcePlaceVO place, String typeNo, int position) {
        switch (typeNo) {
            case "一装一卸":
                LoadingAndUnloadingPlaceActivity.start(this, position, "11", place);
                break;
            case "一装两卸":
                LoadingAndUnloadingPlaceActivity.start(this, position, "12", place);
                break;
            case "两装一卸":
                LoadingAndUnloadingPlaceActivity.start(this, position, "21", place);
                break;
            case "两装两卸":
                LoadingAndUnloadingPlaceActivity.start(this, position, "22", place);
                break;
        }
    }

    private void showTelDialog(String phone) {
        new RoundDialog.Builder(this)
                .title("确认拨号")
                .content(phone)
                .confirm("拨打")
                .cancelable(false)
                .confirmCallback(v -> {
                    Intent intent = new Intent(Intent.ACTION_DIAL);
                    Uri data = Uri.parse("tel:" + phone);
                    intent.setData(data);
                    startActivity(intent);
                })
                .show();
    }
}
